package com.qfedu.edu.seckill.searchservice.utils;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;

/**
 * @author xiaobobo
 * @title: ESUtils
 * @projectName cd-java-2404-seckill-parent
 * @description: ES的这个工具类
 * @date 2025/1/15  14:50
 */
public class ESUtils {

    /**
     * 获取操作ES的这个对象
     * @return
     */
    public static RestHighLevelClient restHighLevelClient() {
        //申明一个存储IP和端口的这样一个类
        HttpHost httpHost = new HttpHost("10.7.183.89", 9200);
        //构建一个Builder对象
        RestClientBuilder builder = RestClient.builder(httpHost);
        //生成咋们的RestHighLevelClient对象
        return new RestHighLevelClient(builder);
    }

}
